package com.yida.gwj.common.domain;

import com.yida.common.core.annotation.Excel;
import com.yida.common.core.web.domain.BaseEntity;
import com.yida.gwj.common.constant.GwjConstants;

/**
 * 业务编号对象 common_business_num
 *
 * @author lqq
 * @date 2022-11-14
 */
public class GwjBaseBusinessNum extends BaseEntity {
	private static final long serialVersionUID = 1L;

	/**
	 * 主键ID
	 */
	@Excel(name = "主键ID")
	private Long bizNumId;

	/**
	 * 年份：yyyy
	 */
	@Excel(name = "年份：yyyy")
	private Integer year;

	/**
	 * 地区编号：00
	 */
	@Excel(name = "地区编号：00")
	private Long areaId;

	/**
	 * 业务编号：00
	 */
	@Excel(name = "业务编号：00")
	private Integer bizFlagId;

	/**
	 * 编号序列：0001开始
	 */
	@Excel(name = "编号序列：0001开始")
	private Long seq;

	public Long getBizNumId() {
		return bizNumId;
	}

	public void setBizNumId(Long bizNumId) {
		this.bizNumId = bizNumId;
	}

	public Integer getBizFlagId() {
		return bizFlagId;
	}

	public void setBizFlagId(Integer bizFlagId) {
		this.bizFlagId = bizFlagId;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	public Integer getYear() {
		return year;
	}

	public void setAreaId(Long areaId) {
		this.areaId = areaId;
	}

	public Long getAreaId() {
		return areaId;
	}

	public void setSeq(Long seq) {
		this.seq = seq;
	}

	public Long getSeq() {
		return seq;
	}

	@Override
	public String toString() {
		return getYear() +
				packAreaId(getAreaId()) +
				packFlagId(getBizFlagId()) +
				packSeq(getSeq());
	}

	/**
	 * 地区ID补全为两位数
	 *
	 * @param areaId 地区ID
	 * @return /
	 */
	private String packAreaId(long areaId) {
		String areaIdStr = String.valueOf(areaId);
		if (areaIdStr.length() == 1) {
			areaIdStr = "0" + areaId;
		}
		return areaIdStr;
	}

	/**
	 * 业务标识ID补全为两位数
	 *
	 * @param flagId 业务标识ID
	 * @return /
	 */
	private String packFlagId(int flagId) {
		String flagIdStr = String.valueOf(flagId);
		if (flagIdStr.length() == 1) {
			flagIdStr = "0" + flagId;
		}
		return flagIdStr;
	}

	/**
	 * 编码序列补全为五位数
	 *
	 * @param seq 编码序列
	 * @return /
	 */
	private String packSeq(long seq) {
		String seqStr = String.valueOf(seq);
		if (seqStr.length() < GwjConstants.BUSINESS_NUM_SEQ_SIZE) {
			StringBuilder zero = new StringBuilder();
			for (int i = 0; i < GwjConstants.BUSINESS_NUM_SEQ_SIZE - seqStr.length(); i++) {
				zero.append("0");
			}
			seqStr = zero.toString() + seqStr;
		}
		return seqStr;
	}
}
